package cn.amoqi.logger.controller.service;

import cn.amoqi.logger.bean.Student;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @Description:
 * @author: zhuiFeng
 * @date: 2021年04月26日 15:43
 */
@Service
public class IndexServiceImpl implements IndexService{


    @Cacheable(value = "cache_index", key = "#id",condition = "#id != null")
    @Override
    public Student getIndex(Long id){
        if(id == null){
            System.out.println("进入null");
            return null;
        }
        System.out.println("没有进入缓存："+id);
        Student build = Student.builder().id(id).name("学生" + id).build();
        return build;
    }
}
